#!/usr/bin/env bash

result=`$(beeline -u "jdbc:hive2://172.18.33.14:10000" -n spark --color --showHeader=false --verbose=true --outputformat=dsv -e "
    SELECT
        CASE WHEN concat_ws(',', sort_array(collect_list(a.label))) = ''
            THEN '-1' ELSE concat_ws(',', sort_array(collect_list(a.label))) END result
    FROM (
        SELECT 1 data_type, '1 - 车辆数' label UNION ALL
        SELECT 2 data_type, '2 - 安全车辆' label UNION ALL
        SELECT 3 data_type, '3 - 装备个数' label UNION ALL
        SELECT 4 data_type, '4 - 结算金额' label UNION ALL
        SELECT 5 data_type, '5 - 油站站点'
    ) a
    LEFT JOIN (
        SELECT data_type FROM dwa_bigscreen.dwa_bigscreen_basic_day_p_daily
        WHERE data_date = 20200730 --AND data_type IN (3, 5)
    ) b ON a.data_type = b.data_type
    WHERE b.data_type IS NULL
")`

if [[ "$result" = "-1" ]]
then
    echo "数据正常"
else
    echo "请排查问题数据: $result"
fi


